<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>产品描述管理 - 产品数据管理系统</title>
<link rel="shortcut icon" href="favicon.ico">
<!-- FontAwesome 4.3.0 -->
<link href="{$fonts.url}font-awesome-4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<!-- Ionicons 2.0.1 -->
<link href="{$fonts.url}ionicons-2.0.1/css/ionicons.min.css" rel="stylesheet" type="text/css" />
<!--bootstrap-->
<link href="{$css.url}bootstrap_min.css" rel="stylesheet" type="text/css" />
<!--AdminLTE theme-->
<link href="{$css.url}AdminLTE_min.css" rel="stylesheet" type="text/css" />
<link href="{$css.url}AdminLT_skins/_all-skins.min.css" rel="stylesheet" type="text/css" />	
<!--datapicker-->
<link href="{$js.url}plugins/datapicker/datepicker.min.css" rel="stylesheet" type="text/css" />
<!--web css-->
<link rel="stylesheet" href="{$css.url}data_optimization_min.css">	
<!--[if lt IE 9]>
    <script src="../js/plugins/html5shiv.min.js"></script>
    <script src="../js/plugins/respond.min.js"></script>
<![endif]-->
{literal}
<style>
.img-thumbnail{width:50px;height:50px;}
.layer-dialog{display:none;}
</style>
{/literal}
</head>
<body class="skin-blue">
<div class="wrapper">
	{include file="bread_crumbs.php"}
	<!--引入面包屑-->
	<section class="data-manage-wrap">
		<div class="row">
			<div class="col-md-12">
				<div class="box">
	                <div class="box-header with-border clearfix">
	                	<div class="box-title pull-left">
	                		<a href="/base/warehouse/addwarehouse" class="btn btn-primary btn-sm"><i class="fa fa-plus mr5"></i>添加仓库</a>
	                		<button type="button" class="btn btn-success btn-sm" id="js_batchCheck"><i class="fa fa-check mr5"></i>批量修改</button>
	                	</div>
	                	<div class="box-form pull-right form-group-sm">
	                		<p class="pull-right"><a href="javascript:;" class="btn btn-success btn-sm" id="js_toggleSearchBox"><i class="fa fa-search"></i><span class="pl5">搜索选项</span></a></p>
	                	</div>
	                	<div class="clearfix"></div>
						<div class="search-box" id="js_searchBox">
							<form action="/base/warehouse/index/" method="get" class="form-inline form-group-sm">								
								<p>
									<label class="control-label">所属事业部：</label>
									<select class="form-control" name="dept_id" id="dept_id">
										<option value="0">所有</option>
										{$depthtml}
									</select>
									<label class="control-label ml10">仓库名称：</label>
									<select class="form-control" name="id" id="id">
										<option value="0">所有</option>
									</select>
									<label class="control-label">仓库代码：</label>
									<input type="text" class="form-control" name="warehouse_code">
									<label class="control-label">添加人：</label>
									<input type="text" class="form-control" name="add_user">
									<label class="control-label">备注：</label>
									<input type="text" class="form-control" name="comment" />
									<label class="control-label ml10">特采数据审核：</label>
									<select class="form-control" name="special_data_examine" id="special_data_examine">
										<option value="">请选择</option>
										<option value="1">无需审核</option>
										<option value="2">一级审核</option>
										<option value="3">二级审核</option>
										<option value="4">三级审核</option>
									</select>
								</p>
							<p class="no-margin">
								<label class="control-label">特采需求审核：</label>
								<select class="form-control" name="special_demand_examine">
									<option value="" selected>请选择</option>
									<option value="1">无需审核</option>
									<option value="2">需要审核</option>
								</select>
								<label class="control-label ml10">需求审核：</label>
								<select class="form-control" name="demand_examine">
									<option value="" selected>请选择</option>
									<option value="1">无需审核</option>
									<option value="2">需要审核</option>
								</select>
								<button type="submit" class="btn btn-primary btn-sm">立即搜索</button>
								<a href="/base/warehouse/index/" class="clear">清除搜索条件</a>
							</p>
							</form>
						</div>
	                </div><!-- .box-header -->
	                <div class="box-body">
	                  <table class="table table-bordered table-striped table-hover" id="js_operateTable">
	                  	<thead>
		                    <tr>
		                      <th width="50"><input name="checkall" type="checkbox"></th>
		                      <th width="80">操作</th>
		                      <th>仓库序号</th>
		                      <th>仓库名称</th>          
		                      <th width="100">所属事业部</th>
		                      <th>仓库代码</th>	
		                      <th width="80">仓库类型</th>	                      
		                      <th>是否发货仓库</th>
		                      <th>是否海外仓</th>
		                      <th>特采数据审核</th>
		                      <th>特采需求审核</th>
		                      <th>需求审核</th>
		                      <th>备注</th>
		                      <th>添加时间</th>
		                      <th>添加人</th>
		                      <th>更新时间</th>
		                      <th>更新人</th>
		                    </tr>
	                    </thead>
	                    <tbody>
	                    	<form action="/base/warehouse/changestatus" id="list_check" id="list">
			                    <tr>
			                    {foreach from=$list item="value"}
			                      <td><input name="warehouse_id[]" type="checkbox" value="{$value.id}"></td>
			                      <td>
			                      		<a href="javascript:void(0);" data-id="{$value.id}" class="btn btn-warning btn-sm" onclick="return locationTo(this);" data-toggle="tooltip" title="编辑"><i class="fa fa-pencil"></i></a>
			                      </td>
			                      <td>{$value.id}</td>
			                      <td>{$value.warehouse_name}</td>
			                      <td>{if isset($depts[$value['dept_id']])}{$depts[$value['dept_id']]['department_name']}{else}-{/if}</td>
			                      <td>{$value.warehouse_code}</td>
			                      <td>{if isset($conf['type'][$value['type']])}{$conf['type'][$value['type']]}{else} <b>未指定</b> {/if}</td>
			                      <td>{$conf['auto_send'][$value['auto_send']]}</td>
			                      <td>{$conf['is_oversea'][$value['is_oversea']]}</td>
			                      <td>{$conf['special_data_examine'][$value['special_data_examine']]}</td>
			                      <td>{$conf['special_demand_examine'][$value['special_demand_examine']]}</td>
			                      <td>{$conf['demand_examine'][$value['demand_examine']]}</td>
			                      <td>{if $value.comment == ''}-{else}{$value.comment}{/if}</td>
			                      <td>{$value['add_time']|date_format:"%Y-%m-%d %H:%M:%S"}</td>
			                      <td>{if $value['add_user'] == ''}-{else}{$value.add_user}{/if}</td>
			                      <td>{$value['modify_time']}</td>
			                      <td>{if $value['operate_user'] == ''}-{else}{$value.operate_user}{/if}</td>
			                    </tr>
			                    {/foreach}
		                    </form>
	                    </tbody>
	              	</table>
	                </div>
	                <!-- .box-body -->
	                <div class="box-footer text-center clearfix">{$page}</div>
	              </div>
			</div>
		</div>
	</section>
</div>

<!--批量审核 弹窗-->
<div class="layer-dialog" id="js_batch_check_dialog">
	<div class="pt15 pl15 pr15">
		<table class="table table-bordered no-margin">
			<form action="" id="mand">
				<tr>
					<td width="130" class="text-right"><b>特采数据审核：<em class="text-star">*</em></b></td>
					<td class="text-left">
						<div class="radio inline pr15"><label><input type="radio" name="special_data_examine" value="1">无需审核</label></div>
						<div class="radio inline pr15"><label><input type="radio" name="special_data_examine" value="2">一级审核</label></div>
						<div class="radio inline"><label><input type="radio" name="special_data_examine" value="3" checked>二级审核</label></div>
						<div class="radio inline"><label><input type="radio" name="special_data_examine" value="4" checked>三级审核</label></div>
		            </td>
				</tr>
				<tr>
					<td width="130" class="text-right"><b>特采需求审核：<em class="text-star">*</em></b></td>
					<td class="text-left">
						<div class="radio inline pr15"><label><input type="radio" name="special_demand_examine" value="1">无需审核</label></div>
						<div class="radio inline pr15"><label><input type="radio" name="special_demand_examine" value="2" checked>需要审核</label></div>
		            </td>
				</tr>
				<tr>
					<td width="130" class="text-right"><b>需求审核：<em class="text-star">*</em></b></td>
					<td class="text-left">
						<div class="radio inline pr15"><label><input type="radio" name="demand_examine" value="2">无需审核</label></div>
						<div class="radio inline"><label><input type="radio" name="demand_examine" value="1" checked id="js_openexame">需要审核</label></div>
						<div class="radio inline"><label><input type="radio" name="demand_examine" value="-" checked id="js_openexame">保持各项原有设置</label></div>
		            </td>
				</tr>
			</form>
		</table>
	</div>
</div>

<!--批量审核 弹窗-->
<div class="layer-dialog" id="js_batch_check_dialog_set">
	<div class="pt15 pl15 pr15">
		<form id="examin_money">
			<table class="table table-bordered no-margin">
				<tr>
					<td width="150" class="text-left">
						<label>
						<input name="leader[auditor]" type="checkbox" value="1" {if isset($warehouse_ex[1])}checked{/if}>
						<input type="hidden" name="leader[id]" {if isset($warehouse_ex[1])}value="{$warehouse_ex[1]['id']}"{/if}>
						<b>组长审核：</b>
						</label>
					</td>
					<td class="col-md-9 text-left form-inline">
						<label>总金额达到 <input type="text" class="form-control" name="leader[quota]" placeholder="请输入数字" value="{if isset($warehouse_ex[1])}{$warehouse_ex.1.quota}{/if}"> 元</label>
						<label>或数量达到 <input type="text" class="form-control" name="leader[maxnum]" placeholder="请输入数字" value="{if isset($warehouse_ex[1])}{$warehouse_ex.1.maxnum}{/if}"> 个</label>
					</td>
				</tr>
				<tr>
					<td width="150" class="text-left">
						<label>
						<input name="director[auditor]" type="checkbox" value="2" {if isset($warehouse_ex[2])}checked{/if}>
						<input type="hidden" name="director[id]" {if isset($warehouse_ex[2])}value="{$warehouse_ex[2]['id']}"{/if}>
						<b>主管审核：</b>
						</label>
					</td>
					<td class="col-md-9 text-left form-inline">
						<label>总金额达到 <input type="text" class="form-control" name="director[quota]" placeholder="请输入数字" value="{if isset($warehouse_ex[2])}{$warehouse_ex.2.quota}{/if}"> 元</label>
						<label>或数量达到 <input type="text" class="form-control" name="director[maxnum]" placeholder="请输入数字" value="{if isset($warehouse_ex[2])}{$warehouse_ex.2.maxnum}{/if}"> 个</label>
					</td>
				</tr>
				<tr>  
					<td width="150" class="text-left">
						<label>
						<input name="manager[auditor]" type="checkbox" value="3" {if isset($warehouse_ex[3])}checked{/if}>
						<input type="hidden" name="manager[id]" {if isset($warehouse_ex[3])}value="{$warehouse_ex[3]['id']}"{/if}>
						<b>经理审核：</b>
						</label>
					</td>                        
					<td class="col-md-9 text-left form-inline">
						<label>总金额达到 <input type="text" class="form-control" name="manager[quota]" placeholder="请输入数字" value="{if isset($warehouse_ex[3])}{$warehouse_ex.3.quota}{/if}"> 元</label>
						<label>或数量达到 <input type="text" class="form-control" name="manager[maxnum]" placeholder="请输入数字" value="{if isset($warehouse_ex[3])}{$warehouse_ex.3.maxnum}{/if}"> 个</label>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>

<!--批量处理 弹窗-->
<div class="layer-dialog" id="js_batch_process_dialog">
	<div class="pt15 pl15 pr15">
		<table class="table table-bordered no-margin">
			<tr>
				<td width="130" class="text-right"><b>文案修改备注：<em class="text-star">*</em></b></td>
				<td><textarea class="form-control" placeholder="A类产品必填"></textarea></td>
			</tr>
		</table>
	</div>
</div>
<div id="w"></div>

<script src="{$js.url}lib/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="{$js.url}lib/bootstrap.min.js" type="text/javascript"></script>	
<script src="{$js.url}plugins/datapicker/bootstrap-datepicker-cn.js" type="text/javascript"></script>
<script src="{$js.url}plugins/layer.js" type="text/javascript"></script>
{literal}
<!--common js-->
<script src="/static/js/common.js"></script>
{/literal}
<script type="text/javascript">
var params = {$params};
$('input[name="warehouse_code"]').val(params['warehouse_code']);
$('input[name="add_user"]').val(params['add_user']);
$('input[name="comment"]').val(params['comment']);
if(params['special_demand_examine'] == ''){
	params['special_demand_examine'] = 0;
}
if(params['demand_examine'] == ''){
	params['demand_examine'] = 0;
}
if(params['special_data_examine'] == ''){
	params['special_data_examine'] = 0;
}
$('select[name="special_demand_examine"] option').eq(params['special_demand_examine']).prop('selected', 'selected');
$('select[name="special_data_examine"] option').eq(params['special_data_examine']).prop('selected', 'selected');
$('select[name="demand_examine"] option').eq(params['demand_examine']).prop('selected', 'selected');
setSelected('dept_id');
setSelected('id');
function setSelected(strID){
    $('#' + strID + ' option').each(function (i){
      if($(this).val() == params[strID]){
        $(this).prop('selected', 'selected');
        return false;
      }
    });
  }
$('input[name="warehouse_code"]').val(params['warehouse_code']);
$('input[name="warehouse_code"]').val(params['warehouse_code']);
{literal}
// 日历控件
$('.js_datePicker').datepicker();
/*$('#js_openexame').click(function (){
  layer.open({
    type:"1",
      title:"需求审核",
      area:["600px","auto"],
      content:$("#js_batch_check_dialog"),
      btn:["确定"],
      yes:function(index){
        layer.close(index);
      }
  });
});*/
// 全选反选
$.fn.check({checkall_name: "checkall", checkbox_name:"warehouse_id[]"});

//获取选中ID
function getSelectedRow(){
	var selectedRowsIdArr = [];
	$('#js_operateTable tbody tr').each(function(i,v){
		var cb = $(v).find("input[name='warehouse_id[]']");
		if(cb.prop("checked")){
			selectedRowsIdArr.push(cb.val());
		}
	});
	return selectedRowsIdArr.join(",");
}

//批量审核
$("#js_batchCheck").on("click",function(){
	var ids = getSelectedRow();
	if(ids){
		layer.open({
			type:"1",
			title:"批量审核",
			area:["600px","auto"],
			content:$("#js_batch_check_dialog"),
			btn:["确定"],
			yes:function(index){
				layer.confirm('是否确定将选中的项修改为当前设定？', function (c){
					$.ajax({
						url : $('#list_check').attr('action'),
						type : 'post',
						dataType : 'json',
						data : $('#list_check').serialize() + '&' + $('#mand').serialize(),
						success : function (result){
							if(result.status){
								setTimeout(function (){
									layer.msg(result.message);
								}, 700);
								layer.close(index);
							}else{
								layer.msg(result.message);
							}
						}
					});
					layer.close(c);
				});
			}
		});
	}else{
		alert("请选择需要审核的产品！")
	}
});

//批量处理
$("#js_openexame").on("click", function(){
	if(getSelectedRow()){
		layer.open({
			type:"1",
			title:"批量处理",
			area:["600px","auto"],
			content:$("#js_batch_check_dialog_set"),
			btn:["确定"],
			yes:function(index){
				layer.confirm('<b style="color:#C33A23">确定之后将立即进行批量修改，是否确定？</b>', function (cl){
					$.ajax({
						url : '/base/warehouse/changewarehouseexamine',
						dataType : 'json',
						type : 'post',
						data : $('#examin_money').serialize() + '&' + $('#list_check').serialize(),
						success : function (result){
							console.log(result);
						}
					});
					layer.close(cl);
				});
			}
		});
	}else{
		alert("请选择需要审核的产品！")
	}
});


$('#dept_id').change(dept);
function dept(){
	var did = $(this).find('option:selected').val();
	var str = '<option value="0">所有</option>';
	$.ajax({
		url : '/base/warehouse/getselectedwarehousebydeptid',
		data : {did : did},
		dataType : 'json',
		type : 'get',
		success : function (result){
			$.each(result, function(i, n){
				str += '<option value="' + n.id + '">' + n.warehouse_name + '</option>' + "\r\n";
			});
			$('select[name="id"]').html(str);
		}
	});
}
//批量删除
$("#js_batchDelete").on("click",function(){
	if(getSelectedRow()){
		layer.confirm("确定删除吗？",function(index){
			//删除ajax写在这里！
			layer.close(index);
		});
	}
	else{
		alert("请选择需要删除的产品！")
	}
});
locationTo = function (elem){
	location.href = '/base/warehouse/edit?id=' + elem.getAttribute('data-id');
}
dept();
{/literal}
</script>
</body>
</html>
